//
//  BlurView.swift
//  SwiftUiBaseStudy
//
//  Created by Daniel on 2023/11/13.
//

import SwiftUI

struct BlurView: UIViewRepresentable {
    typealias UIViewType = UIView
    
    var style:UIBlurEffect.Style = .systemMaterial
    
    func makeUIView(context: UIViewRepresentableContext<BlurView>) -> UIView {
        let view = UIView()
        view.backgroundColor = .clear
        
        let blurEeffect = UIBlurEffect(style: style)
        let blurEeffectView = UIVisualEffectView(effect: blurEeffect)
        
        blurEeffectView.translatesAutoresizingMaskIntoConstraints = false
        
//        view.addSubview(blurEeffectView)
        view.insertSubview(blurEeffectView, at: 0)
        
        NSLayoutConstraint.activate([
            blurEeffectView.widthAnchor.constraint(equalTo: view.widthAnchor),
            blurEeffectView.heightAnchor.constraint(equalTo: view.heightAnchor),
        ])
        
        return view
    }
    
    func updateUIView(_ uiView: UIView, context: UIViewRepresentableContext<BlurView>) {
        
    }
    
    
}
